package qmlt.learning.decisiontree.utils;

import java.util.Map;

import qmlt.dataset.Instance;
import qmlt.learning.decisiontree.Node;

public class DecisionTreeUtils
{
    public static int countMislabeledIfPruned(Node node, Object majorLabel)
    {
        int mislabeled = 0;

        for (Instance inst : node.predictedInstances)
        {
            if (!inst.getTarget().equals(majorLabel))
                mislabeled++;
        }

        return mislabeled;
    }

    public static int countMislabeled(Node node, Map<Instance, Object> predictions)
    {
        int mislabeled = 0;

        for (Instance inst : node.predictedInstances)
        {
            if (!inst.getTarget().equals(predictions.get(inst)))
                mislabeled++;
        }

        return mislabeled;
    }
}
